﻿var nameid = "ADM.MenuOrganizerNAME";
var urlid = "ADM.MenuOrganizerURL";

AddMenuOrganizer = function(){
    var hf = $id("hfAdd");
    var btn = $id("btnAdd");
    hf.value = "add";
    
    var name = $id(nameid);
    var url = $id(urlid);
    
    name.style.backgroundColor = name.value == "" ? "#FFAAAA" : "#FFFFFF";
    url.style.backgroundColor = url.value == "" ? "#FFAAAA" : "#FFFFFF";
    
    if( name.value == "" || url.value == "" )
    {
        alert("Mohon lengkapi form");
        return false;
    }
    
    dgMain_c.PerformCallback( hf.value + DELIMITER + name.value + DELIMITER + url.value );
    
    btn.style.display = "none";
}

DeleteMenuOrganizer = function(id){
    if(confirm("Delete MenuOrganizer?"))
    {
        var hf = $id("hfAdd");
        hf.value = "del";
        dgMain_c.PerformCallback( hf.value + DELIMITER + id );
    }
}

ToggleValidity = function(id){
    var hf = $id("hfAdd");
    hf.value = "toggle";
    dgMain_c.PerformCallback( hf.value + DELIMITER + id );
}

dgMain_c_CallbackComplete = function(e){
    var hf = $id("hfAdd");
    if( hf.value == "add" )
    {
        var btn = $id("btnAdd");
        var name = $id(nameid);
        var url = $id(urlid);
        
        name.value = url.value = "";    
        btn.style.display = "";
    }
}

toggle = function (fsid)
{
    var div = $id("div_" + fsid);
    var lnk = $id("lnk_" + fsid);
    
    var display = "";
    
    if( div.style.display != "none" )
    {
        display = "none";
    }
    
    div.style.display = display;
    
    if( lnk != null )
    {
        lnk.style.display = display;
    }
}

StartLoadingAnimation = function(div){
    div.innerHTML = "<img src='" + LOADING.src + "' alt='' />";    
}

EndLoadingAnimation = function(div){
    div.innerHTML = "";    
}